package com.ywl.study.transaction.util;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class Task {
    private Lock lock=new ReentrantLock();
    private Condition condition=lock.newCondition();

    public void waitTask(){
        try {
            lock.lock();
            condition.await();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }finally {
            lock.unlock();
        }
    }

    public void siganlTask(){
        lock.lock();
        condition.signal();
        lock.unlock();
    }

    public static void main(String[] args) {
        new Task().waitTask();
    }
}
